/**
 * 
 */
package model.turtle;

/**
 * 
 */
public class Position
{
	public static final int MAX = 360;
	public int x;
	public int y;
	private int direction;
	
	public Position(int x, int y, int d){
		this.x = x;
		this.y = y;
		setDirection(d);
	}
	
	public Position(Position p) {
		x = p.x;
		y = p.y;
		direction = p.direction;
	}
	
	public int getDirection() {
		return direction;
	}
	
	public void setDirection(int d) {
		this.direction = d % MAX;
		if(this.direction < 0) this.direction += MAX; // Deal with odd behavior of mod.
	}
	
	@Override
	public boolean equals(Object o) {
		if(!(o instanceof Position)) return false;
		Position p = (Position) o;
		return x == p.x && y == p.y && direction == p.direction;
	}
	
	@Override
	public String toString() {
		return String.format("[%d, %d, %d]", x, y, direction);
	}
}
